import { defineStore } from 'pinia'
interface ITabsType {
  name: string
  path: string
}
interface routerType {
  routerList: any[]
  TabsList: ITabsType[]
  currentPath: ITabsType
  refresh: boolean
}
export const useRouterStore = defineStore('router', {
  state: (): routerType => ({
    routerList: [],
    TabsList: [{ name: 'echarts列表', path: '/main/system/role' }],
    currentPath: { name: 'echarts列表', path: '/main/system/role' },
    refresh: true,
  }),
  actions: {
    changeRouterList(list: any) { },
    changeCurrentPath(router: ITabsType) {
      this.currentPath = router
    },
    changeTabsList(routerList: ITabsType) {
      const result = this.TabsList.find((item) => item.path === routerList.path)
      if (!result) {
        this.TabsList.push(routerList)
      }
    },
    setRefresh(value: boolean) {
      this.refresh = value
    },
  }
})
